package problema048;

import java.math.BigInteger;

public class SelfPowers {

	public static void main(String[] args){
		selfPowers();
	}
	
	public static void selfPowers(){
		BigInteger res = new BigInteger("0"), mult = new BigInteger("1"), cant = new BigInteger("10000000000"), act;
		for(Integer i = 1; i <= 1000; i++){
			act = new BigInteger(i.toString());
			mult = new BigInteger(i.toString());
			for(int j = 1; j < i; j++){
				mult = mult.multiply(act);
				mult = mult.mod(cant);
			}
			res = res.add(mult);
			res = res.mod(cant);
		}
		System.out.println(res);
	}
	
}
